﻿-var date = (DateTime)ViewData["Date"]
-var firstday = (DateTime)ViewData["Firstday"]
-var whs = new IWorkingHours[7];
-var schedule = ViewData["Schedule"] as Schedule
%table.schedule.week
  %tr
    %th{width="50"}
    -for(int d=0;d<7;d++)
      -var cdate = firstday.AddDays(d)
      -if(schedule!=null)
        -whs[d] = schedule.GetWorkingHours(cdate)
      %th{width="14%"}
        %span.sday=cdate.ToString("ddd, dd")
        %span.smonth=cdate.ToString("MMM")
  -for(int h=0;h<24;h++)
    %tr
      %th
        =h.AddLeadingZero(2)+":00"
      -for(int d=0;d<7;d++)
        -string cls="active"
        -bool first = false;
        -if(whs[d]!=null && whs[d].TimeStart.HasValue)
          -if(whs[d].TimeStart.Value.Hour <= h && whs[d].TimeEnd.Value.Hour >= h && !(whs[d].BreakStart.HasValue && whs[d].BreakStart.Value.Hour <=h && whs[d].BreakEnd.Value.Hour >= h) )
            -cls+=" wh"
            -if(h==whs[d].TimeStart.Value.Hour)
              -first = true;
        %td{class=cls}
          ="&nbsp;"
          -if(first)
            =whs[d].TimeStart.Value.ToCssTimeString()
            =whs[d].SchedulePeriod.Name